<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Vue基础呀</title>
  </head>

  <body>
    <div id = "app">
      <input type="button" value="v-on指令" v-on:click="doIt">
      <input type="button" value="v-on简写" @click="doIt">
      <input type="button" value="双击v-on" @dblclick="doIt"> <!-- 双击 -->
      
      <h2 @click="clickFood"> {{food}}</h2>

    </div>


    

    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

    <script>
      new Vue({
        el:"#app",
        data:{
          food:"好吃的食物"

        },

        
        methods: {
          doIt:function(){
            alert("你点击了一次——来自alert")
          },
          clickFood:function(){
            console.log(this.food)
            this.food+=" 点赞! "
          }
        
        }

      })
    </script>

    <!-- data是这个Vue实例中使用到的数据。用什么就写什么 -->
  </body>
</html>
